export interface IStateItem {
    id: number,
    username: string,
    password: string,
    permission: {
        key: number,
        label: string
    }
}

// 详情和列表是不一样的不要用同一个接口
export interface IAdminDetail {
    id: number,
    username: string,
    password: string,
    permission: number,
    avatar_url: string
}

interface IAdminDetailParam {
    id: number
}

interface IAdminListParam {
    page_size: number,
    current_page: number,
    search_content?: string
}

interface IDeleteAdminParam {
    admin_id: number
}

interface IAddAdminParam {
    username: string,
    password: string,
    permission: number
}

interface IUpdateAdminParam {
    id: number,
    username: string,
    password: string,
    permission: number
}

interface IUpdateAdminSelfParam {
    password: string
}

export interface IState {
    adminInfo: {
        data: Array<IStateItem>,
        page_info: {
            current_page: number,
            page_size: number,
            total_count: number
        }
    },
    currentAdminDetail: IAdminDetail
}

export interface IActions {
    requestAdminDetailAction: (params: IAdminDetailParam) => void,
    requestAdminListAction: (params: IAdminListParam) => void,
    deleteAdminAction: (params: IDeleteAdminParam) => Promise<boolean>,
    addAdminAction: (params: IAddAdminParam) => Promise<boolean>,
    updateAdminAction: (params: IUpdateAdminParam) => Promise<boolean>,
    updateAdminSelfAction: (params: IUpdateAdminSelfParam) => Promise<boolean>
}

// 加个enum
export enum URL_TYPE {
    ADMIN_DETAIL = "admin/detail",
    ADMIN_ADD = "admin/add",
    ADMIN_DELETE = "admin/delete",
    ADMIN_LIST = "admin/list",
    ADMIN_UPDATE = "admin/update",
    ADMIN_UPDATE_SELF = "account/update",
}
